package com.nsoft.remoteserver;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;

import javax.swing.BorderFactory;
import javax.swing.JDesktopPane;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.ListSelectionModel;

import com.nsoft.remoteserver.utils.Constant;

@SuppressWarnings("rawtypes")
public class VideoPlayerPanel extends JPanel {

	private static final long serialVersionUID = 1L;
	private JList videoSourceList;
	private JDesktopPane videoFrameList;
	
	public VideoPlayerPanel(){
		this.setLayout(new BorderLayout());
		
		JPanel listPanel=new JPanel(new BorderLayout());
		/**
		 * left panel - list of video sources
		 */
		listPanel.add(new JLabel(
				Constant.ui.TEXT_VIDEO_SOURCE_LIST),
					BorderLayout.NORTH);
		
		videoSourceList=new JList<>();
		videoSourceList.setSelectionMode(
				ListSelectionModel.SINGLE_INTERVAL_SELECTION);
		JScrollPane listScroller=new JScrollPane(
				videoSourceList,
				JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
				JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
		listScroller.setPreferredSize(new Dimension(250,80));
		listScroller.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
		listPanel.add(listScroller,BorderLayout.CENTER);
		
		/**
		 * right panel - list of video frames that being played
		 */
		JPanel viewPanel=new JPanel(new BorderLayout());
		
		videoFrameList=new JDesktopPane();
		videoFrameList.setBorder(BorderFactory.
						createLineBorder(Color.LIGHT_GRAY));
		videoFrameList.setBackground(Color.LIGHT_GRAY);
		
		JScrollPane frameScroller=new JScrollPane(
				videoFrameList,
				JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
				JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
		frameScroller.setBorder(BorderFactory.createEmptyBorder());
		
		viewPanel.add(frameScroller,BorderLayout.CENTER);
		
		JSplitPane mainSplitter=new JSplitPane(
						JSplitPane.HORIZONTAL_SPLIT,
						listPanel,viewPanel);
		mainSplitter.setOneTouchExpandable(true);
		
		add(mainSplitter,BorderLayout.CENTER);
	}
}
